<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>钻石之家---购物车</title>
    <style>
        .table-new{
            border: 0;
        }
        .table-new td{
            border: 0;
        }

        #cart_reduce,#cart_add{
            cursor:pointer;
        }

        .address{
            border: 1px solid red;
        }
        .new_address{
            margin-left: 75px;
            margin-top: 50px;
        }

    </style>
</head>
<body>
{:widget('Cate/header')}
<div class="breadcrumbs">
    <div class="container_12">
        <div class="grid_12">
            <a href="index.html">Home</a><span></span><a href="#">Category</a><span></span><span class="current">This page</span>
        </div><!-- .grid_12 -->
    </div><!-- .container_12 -->
</div><!-- .breadcrumbs -->

<section id="main">
    <div class="container_12">
        <div id="content" class="grid_12">


            <article>
                <table class="cart_product layui-form" id="test">
                    <tr class="bg">
                        <th class="images">订单号</th>
                        <th class="images">收货人</th>
                        <th class="images">收货地址</th>
                        <th class="images">联系电话</th>
                        <th class="name">订单金额</th>
                        <th class="price">下单时间</th>
                        <th class="price">订单状态</th>
                        <th class="price">是否收货</th>
                    </tr>
                {if !empty($res)}
                 {foreach $res as $val}
                    <tr id="foreachs">
                        <td class="name" align="center"><a href="/orders/detail/id/{$val.id}">{$val.id}</a></td>
                        <td class="price"><i>{$val.address_name}</i></td>
                        <td class="name"><i>{$val.address_address}{$val.address_detailed}</i></td>
                        <td class="price"><i>{$val.address_phone}</i></td>
                        <td class="price">￥<i>{$val.total}</i></td>
                        <td class="price"><i>{$val.create_time}</i></td>
                        <td class="price" id="states">
                            <i>
                            {if $val.status=='0'}
                            等待付款
                            {elseif $val.status=='1'}
                            待发货
                            {elseif $val.status=='2'}
                            待收货
                            {elseif $val.status=='3'}
                            已收货
                            {elseif $val.status=='4'}
                             待评价
                             {elseif $val.status=='5'}
                             已评价
                             {/if}
                          </i>
                        </td>
                        <td class="qty" >
                            {if $val.status>='3'}
                            <a title="收货" style="text-decoration:none"> 收货</a>
                            {else}
                            <a onClick="shou(this,'{$val.id}')" href="javascript:;" title="收货"> 确认收货</a>
                           {/if}
                        </td>
                    </tr>
                {/foreach}
                {else}
                    <tr><td colspan="9">没有订单</td></tr>
                {/if}
                </table>
            </article>
</section><!-- #main -->
<div class="clear"></div>

{:widget('Cate/footer')}
</body>
<script>

    layui.use(['form','layer','table'], function() {
        //弹窗
        var layer = layui.layer;
        var form = layui.form;

    });

    /*收货-停用*/
    function shou(obj,id) {
        layer.confirm('确认收货？', function (index) {
            //请求控制器进行状态的变更
            $.ajax({
                'type': 'post',//请求的方式
                'data': {'id': id},//附加参数
                'async': true,//异步操作
                'url': "aces",//服务器端页面
//            'dataType':"json",//响应数据类型
                //接受响应数据的匿名函数
                success: function (data) {
                    if(data.status==0){
                        $(obj).html('<i>收货</i>');
                        $(obj).parents("tr").find("#states").html('<i>已收货</i>');
                        $(obj).attr('onclick',' ');
                        $(obj).remove();
                        layer.msg(data.msg, {icon: 5, time: 1000});
                    }else{
                        layer.msg(data.msg, {icon: 5, time: 1000});
                    }

                },
                //Ajax 发送失败
                error: function () {
                }
            })
            //此处请求后台程序，下方是成功后的前台处理……
        });
    }
</script>
</html>